package com.zr.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.zr.service.ProxyService;

import net.sf.json.JSONObject;

//代理点action
@Controller
@Scope(value="prototype")
public class Proxys implements ServletResponseAware{
	private HttpServletResponse resp;
	private int page;
	private int rows;
	
	
	public int getPage() {
		return page;
	}
	public void setPage(int page) {
		this.page = page;
	}
	public int getRows() {
		return rows;
	}
	public void setRows(int rows) {
		this.rows = rows;
	}
	@Resource
	private ProxyService proxyss;
	
	public void proxyss(){
		resp.setCharacterEncoding("UTF8");
		JSONObject j = proxyss.findAllProxys(page, rows);
		PrintWriter pw;
		try {
			pw = resp.getWriter();
			pw.write(j.toString());
			pw.flush();
			pw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	@Override
	public void setServletResponse(HttpServletResponse resp) {
		this.resp=resp;
	}
	
}
